//index.js
var WxParse = require('../../wxParse/wxParse.js');
//获取应用实例 
var app = getApp()
Page({
  data: {
    articleMsg:[],
    showIndex: 0,
  },
  onShow:function(){
    
  },
  onReady:function(){
   
  },
  onLoad: function () {
    this.getMsg();
  },

  //获取文章内容
  getMsg() {
    var that = this;
    wx.request({
      url: app.globalData.api + '/index.php/wap/Article/getList',
      data:
      {
        cat_id: 3,
      },
      headers: {
        'platform': '' + app.globalData.platform,
        'version': '' + app.globalData.version,
      },
      method: 'POST',
      dataType: 'json',
      success: function (res) {
        // console.log(res);
        if (res.data.code == 1) {
          for (var i = 0; i < res.data.data.list.length;i++){
            res.data.data.list[i].img = app.globalData.imgUrl + "" + res.data.data.list[i].img.replace(/\\/g, "/");
          }
          that.setData({
            helpList:res.data.data.list
          })
          console.log(that.data.helpList)
        } else {
          wx.showToast({
            title: '' + res.data.msg,
            icon: 'none',
            duration: 1000
          })
        }

      }, fail: function () {

      }
    });
  },
  onReady: function () {
    wx.setNavigationBarTitle({
      title: '帮助中心'
    })
  },
  panel: function (e) {
    if (e.currentTarget.dataset.index != this.data.showIndex) {
      this.setData({
        showIndex: e.currentTarget.dataset.index
      })
    } else {
      this.setData({
        showIndex: 0
      })
    }
  },
})
